package com.gmall.rabbitmq.producer.controller;

import com.gmall.rabbitmq.config.RabbitMQConfig_Delay;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("delay")
public class DelayController {

    @Autowired
    RabbitTemplate rabbitTemplate;
    @PostMapping("")
    public String producerMessage1(){

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        rabbitTemplate.convertAndSend(RabbitMQConfig_Delay.Exchange_Business_delay_direct,
                RabbitMQConfig_Delay.Business_RoutingKey_delay_1,
                simpleDateFormat.format(new Date()));

        return "OK";
    }



}
